import { createStore, Store, useStore as BaseUseStore } from "vuex";
import { InjectionKey } from "vue";

import { About } from "./module/about";

export interface State {
  root: string;
}

const key: InjectionKey<Store<State>> = Symbol("vuex");

export default createStore({
  state: {
    root: "123",
  },
  mutations: {
    setRoot(state, value) {
      state.root = value;
    },
  },
  actions: {
    setRoot(context, value) {
      context.commit("setRoot", value);
    },
  },
  getters: {
    total(state, getters) {
      return 'rootGetters';
    },
  },
  modules: {
    about: About,
  },
});

const useStore = () => {
  return BaseUseStore(key);
};

export { key, useStore };
